﻿using System;
using System.Globalization;
using DailyPoetryX.Models;
using DailyPoetryX.Util;
using Xamarin.Forms;

namespace DailyPoetryX.Converters {
    public class PoetryToStringConverter : IValueConverter {
        public object Convert(object value, Type targetType, object parameter,
            CultureInfo culture) =>
            !(value is Poetry poetry)
                ? null
                : $"{poetry.Dynasty} · {poetry.AuthorName}    {poetry.Snippet}";

        public object ConvertBack(object value, Type targetType,
            object parameter, CultureInfo culture) {
            throw new DoNotCallThisExcpetion();
        }
    }
}